<template>
  <div class="u-p-20">
    <el-card shadow="never">
      <el-table :data="tableData" class="u-mt-10" v-viewer @selection-change="handleSelectionChange">
        <el-table-column label="序号" type="index" :index="getIndexNo" width="60"></el-table-column>
        <el-table-column type="selection" width="55"></el-table-column>
        <el-table-column label="图片">
          <template slot-scope="scope">
            <el-image
              style="'width: 150px; height: 80px"
              :src="scope.row.banner_src+'?x-oss-process=image/auto-orient,1/resize,m_fill,w_200,h_60/quality,q_100'"
              :data-src="scope.row.banner_src"
              fit="cover"
              lazy
            ></el-image>
          </template>
        </el-table-column>
        <el-table-column label="标题" prop="banner_title"></el-table-column>
        <el-table-column label="跳转类型">
          <template slot-scope="scope">
            <el-tag v-if="scope.row.jump_type==1">商品页面</el-tag>
            <el-tag type="success" v-else-if="scope.row.jump_type==2">外部链接</el-tag>
            <el-tag type="info" v-else>无跳转</el-tag>
          </template>
        </el-table-column>

        <el-table-column label="跳转参数">
          <template slot-scope="scope">
            <el-tag v-if="scope.row.jump_type==1">{{scope.row.goods_id}}</el-tag>
            <el-tag type="success" v-else-if="scope.row.jump_type==2">{{scope.row.jump_link}}</el-tag>
            <el-tag type="info" v-else>无跳转</el-tag>
          </template>
        </el-table-column>

        <el-table-column label="上线状态">
          <template slot-scope="scope">
              {{scope.row.status?'上线':'下线'}}
            <!-- <el-switch
              v-model="scope.row.status"
              :active-value="1"
              :inactive-value="0"
              active-color="#13ce66"
              @change="handleStatus(scope.row.id,scope.row.status)"
            ></el-switch> -->
          </template>
        </el-table-column>
        <!-- <el-table-column label="排序" prop="rank"></el-table-column> -->
        <el-table-column label="生效时间" prop="start_time" sortable></el-table-column>
        <el-table-column label="失效时间" prop="end_time" sortable></el-table-column>
      </el-table>
      <div class="u-mt-20 u-text-center">
        <el-pagination
          background
          @size-change="handleSizeChange"
          @current-change="handlePageChange"
          :current-page="currentPage"
          :page-sizes="[10, 20, 30, 40, 50]"
          :page-size="limit"
          layout="total, sizes, prev, pager, next, jumper"
          :total="total"
        ></el-pagination>
      </div>
    </el-card>
  </div>
</template>

<script>
import commonPage from "@/mixins/common-page";

export default {
    props:{
        objform:{
            type:Object,
            default: function () {
                return {}
            }
        }
    },
  mixins: [commonPage],
  data() {
    return {
      apiPage:'page2',
      apiName: "companyBanner",
      queryForm: {
        status: "",
        area:"all",
        jump_type: "",
        keyword:""
      },
    };
  },
  methods: {
      getPageData2(){
          this.getPageData(true);
      },
      handleSelectionChange(val) {
        let arr=[]
        val.map((item) => {
          arr.push(item.id);
        });
        this.$emit('onChecked',arr)
      },
  },
  watch: {
      objform:{
          deep: true,
          immediate: true,
          handler(val){
            this.queryForm.keyword=val.keyword
          }
      }
  },
};
</script>
